public class Work12 {
    public static void main(String[] args) {
        int i=30;
        int sum=0;
        for(i=10;i<1000;i++){
            if((i/10)%10==3&&(i%7==0)&&(i%11==0)){
                sum=sum+i;
            }
        }
        System.out.print(sum);
    }
}

